package pilgun.Multithread.BigInteger;

import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicReference;

class BigIntegerGenerator {
	private static AtomicReference<BigInteger> num = new AtomicReference<BigInteger>(BigInteger.valueOf(1));
	public static BigInteger BigIntegerNext() {
		for (;;) {
			BigInteger current = num.get();
			BigInteger next = current.multiply(BigInteger.valueOf(2));
			if (num.compareAndSet(current, next))
				return next;
		}
	}

}